# -*- coding: utf-8 -*-

"""
@Datetime: 2019/1/2
@Author: Zhang Yafei
"""
from Kingadmin.admin_base import BaseKingAdmin


class AdminSite(object):

    def __init__(self):
        self.enable_admins = {}

    def register(self, model_class, admin_class=None):
        model_name = model_class.__tablename__
        if not admin_class:
            admin_class = BaseKingAdmin()  #为了避免多个admin_class共享同一个BaseKingAdmin对象,要实例化
        else:
            admin_class = admin_class()
        admin_class.model = model_class
        if model_name not in self.enable_admins:
            self.enable_admins[model_name] = {}
        self.enable_admins[model_name] = admin_class


site = AdminSite()




